package com.example.testapp.activity.fragment;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.example.testapp.activity.http.RetryNetwork;
import com.example.testapp.activity.listener.PwdErrorListener;
import com.example.testapp.activity.model.Info;
import com.example.testapp.activity.util.IBackEventStrategy;
import com.example.testapp.activity.util.ThreadPoolManager;

/**
 * Created by l on 2016/11/3.
 */

public class SuperFragment extends Fragment implements RetryNetwork, PwdErrorListener, IBackEventStrategy{
    private static final String TAG = "SuperFragment";

    protected Context  mContext;
    protected Activity mActivity;
    protected ProgressDialog  mProgress;
    protected Info mInfo;
    protected ThreadPoolManager  mThreadPoolManager;

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mContext = getActivity();
        mActivity = getActivity();
        mThreadPoolManager = ThreadPoolManager.getInstance();
        mProgress = getProgressDialog("正在加载,请稍后...");
        mProgress.setCancelable(true);
        obtainInfo();
    }

    private ProgressDialog getProgressDialog(String msg) {
        ProgressDialog progressDialog = new ProgressDialog(mContext);
        progressDialog.setMessage(msg);
        progressDialog.setCancelable(true);
        return progressDialog;
    }

    /**
     * 获取数据bean的逻辑统一放在这里
     */
    private void obtainInfo() {

    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (!hidden){
            obtainInfo();
        }else{

        }
    }

    @Override
    public void retry() {

    }

    @Override
    public void netError() {

    }

    @Override
    public void pwdError() {

    }

    @Override
    public boolean backOperate() {
        return false;
    }
}
